decisions = {
	form_wre_dec = {
		only_independent = yes
		is_high_prio = yes
		ai_check_interval = 1
		
		potential = {
			is_playable = yes
			conditional_tooltip = {
				trigger = {
					is_alternate_start = no
				}
			}
			NOT = { has_global_flag = rome_restored }
			independent = yes
			has_landed_title = e_italy
			culture_group = latin
			NOT = { religion = catholic }
			NOT = { religion = fraticelli }
			NOT = { has_landed_title = e_byzantium }
			NOT = { has_landed_title = e_rum }
			NOT = { has_landed_title = k_rum }
			NOT = {
				has_alternate_start_parameter = { key = religion_names value = random }
			}
			e_hre = {
				has_holder = no
			}
		}
		allow = {
			is_adult = yes
			prisoner = no
			NOT = { trait = incapable }
			prestige = 1000
			custom_tooltip = {
				text = HREREALMSIZETWOTWENTY
					OR = {
						realm_size = 220
						}
					}
			conditional_tooltip = {
				trigger = {
					is_alternate_start = no
				}
				has_landed_title = e_italy
				custom_tooltip = {
					text = form_the_hre_early_tooltip_2
					hidden_tooltip = {
						any_demesne_title = {
							OR = {
								title = e_france
								title = e_germany
								title = e_britannia
								title = e_spain
								AND = {
									tier = KING
									NOT = {	title = k_italy	}
									OR = {
										empire = { title = e_france }
										empire = { title = e_germany }
										empire = { title = e_britannia }
										empire = { title = e_spain }
									}
								}
							}
						}
					}
				}
			}
			scaled_wealth = 2
	}
		effect = {
			custom_tooltip = {
			text = wreiscreated
			set_global_flag = charlemagne_hre
			activate_title = { title = e_hre status = yes }
			e_hre = {
			set_name = "Western Roman Empire"
			adjective = "Western Roman"
			set_coa = e_italy
			}
			if = {
				limit = {
					ai = no
				}
				scaled_wealth = -2
			}
			if = {
				limit = { has_nickname = no }
				give_nickname = nick_the_great
			}
			primary_title = {
				show_scope_change = no
				e_hre = {
					show_scope_change = no
					grant_title = ROOT
					copy_title_laws = PREV
					set_name = "Western Roman Empire"
					adjective = "Western Roman"
					set_title_flag = hre_is_wre
				}
			}
			any_demesne_title = {
				limit = { tier = KING }
				de_jure_liege = e_hre
			}
			hidden_tooltip = {
				any_demesne_title = {
					if = {
						limit = { tier = EMPEROR }
						any_direct_de_jure_vassal_title = {
							de_jure_liege = e_hre
						}
					}
				}
			}
			any_demesne_title = {
				limit = {
					tier = EMPEROR
					NOT = { title = e_hre }
				}
				destroy_landed_title = THIS
				hidden_tooltip = { activate_title = { title = THIS status = no } }
			}
			any_demesne_title = {
				limit = { tier = KING }
				destroy_landed_title = THIS
			}
			e_byzantium = {
				show_scope_change = no
				holder_scope = {
					show_scope_change = no
					opinion = {
						who = ROOT
						modifier = opinion_unhappy
						months = 1200
					}
					hidden_tooltip = {
						k_papal_state = {
							holder_scope = {
								reverse_opinion = {
									who = PREVPREV
									modifier = opinion_unhappy
									months = 1200
								}
							}
						}
					}
				}
			}
			if = {
				limit = {
					OR = {
						NOT = {	has_character_flag = is_charlemagne }
						has_character_flag = charlemagne_coronation
					}
				}
				add_artifact = crown_hre
			}
			if = {
				limit = {
					has_character_flag = is_charlemagne
					NOT = { has_character_flag = charlemagne_coronation }
				}
				hidden_tooltip = { narrative_event = { id = CM.1500 } }        # Charlemagne coronation
			}
			if = {
				limit = { ai = no }
				set_character_flag = achievement_holy_and_roman
			}
			ROOT = {
				narrative_event = { id = LOREXP.00022 }
			}
			any_playable_ruler = {
				narrative_event = { id = LOREXP.00022 }
			}
		}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
		}
}
}